<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Iterator for Prototype</title>
</head>

<body>
    <script>
        Object.prototype[Symbol.iterator] = function() {
            return this;
        }
        Object.prototype.next = function() {
            let i = 'a' + (++index);
            if( !obj[i] ) {
                return {done: true};
            }
            else {
                return {value: obj[i]};
            }
        };

        let index = 0;
        let obj = {a1: 10, a2: 20, a3: 30};
        for(let x of obj) {
            console.log(x);
        }
    </script>
</body>

</html>